/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86184
 * Date: 2023-02-17
 * Time: 13:37
 */

//抽象类
abstract class Animal{
    //抽象方法
    public abstract void animal();

    public void func(){
        System.out.println("动物大纲");
    }
}

//普通类继承抽象类，必须重写抽象方法
class Dog extends Animal{
    @Override
    public void animal(){
        System.out.println("狗子");
    }
}

class Cat extends Animal{
    @Override
    public void animal(){
        System.out.println("小猫");
    }
}
//抽象类A继承抽象类可以不用重写抽象方法
abstract class A extends Animal{

}
//但普通类在继承抽象类A需要重写继承方法
class Monkey extends Animal{
    @Override
    public void animal(){
        System.out.println("猴子");
    }
}

public class AbstractClass {

    public static void function(Animal animal1){
        animal1.animal();
    }
    public static void main(String[] args) {
        //Animal animal11=new Animal();  不可以new抽象类
        Dog dog=new Dog();
        Cat cat=new Cat();
        Monkey monkey=new Monkey();
        function(dog);
        function(cat);
        function(monkey);
    }
}
